<?php

namespace App\Models\Sms;

use App\Models\BaseModel;

class SmsWayModel extends BaseModel
{
    /**
     * 与模型关联的数据表。
     *
     * @var string
     */
    protected $table = 'sms_way';

    /**
     * 可以被批量赋值的属性。
     *
     * @var array
     */
    protected $fillable = array(
        'name',
        'path',
        'url',
        'parame',
        'shop_id',
        'created_at',
        'remark',
        'anb',
        'is_yzm',
    );
    // public $timestamps = false; // 防止updated_at 报错

    public function aliasRable($alias)
    {
        return $this->setTable($alias);
    }
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y-m-d H:i:s');
    }

    //返回关键字段
    public function getTableField()
    {
        return $this->fillable;
    }
    /**
     * 建表语句
     */
    protected function buildTable($name = '')
    {
        $tablename = $this->table;
        if (!empty($name)) {
            $tablename = $name;
        }
        $table  = "CREATE TABLE `card_sms_way`  (
            `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID',
            `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '通道名称',
            `path` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '方法的路径',
            `url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '访问的地址',
            `parame` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '参数',
            `shop_id` int(11) NULL DEFAULT 0 COMMENT '店铺id',
            `created_at` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
            `remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
            `anb` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '异常信息',
            `is_yzm` tinyint(2) NULL DEFAULT 0 COMMENT '消息类型:1=验证码,0=通知',
            PRIMARY KEY (`id`) USING BTREE
          ) ENGINE = InnoDB AUTO_INCREMENT = 244 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = 'sms通道表' ROW_FORMAT = Dynamic;";
        return $table;
    }
    public function isYzmRemark()
    {
        return [
            0 => '通知',
            1 => '验证码',
        ];
    }
}
